﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WebEngine
{
	// Designed as Singleton
	public sealed class SingleWEBProxy
	{
		static readonly SingleWEBProxy m_Instance = new SingleWEBProxy();

		// Explicit static ctor to tell c# compiler 
		// not to mark type as beforefieldinit
		// to gurantee that instance member is instantiated
		static SingleWEBProxy()
		{
		}

		SingleWEBProxy()
		{
		}

		public static SingleWEBProxy Instace
		{
			get
			{
				return m_Instance;
			}
		}

		public double DollarRate
		{
			get
			{
				double resultRate = 0;
				CurrencyConvertor.CurrencyConvertor cc = new CurrencyConvertor.CurrencyConvertor();

				// Getting Dollar Rate using an external WebService
				resultRate = cc.ConversionRate(CurrencyConvertor.Currency.USD, CurrencyConvertor.Currency.ILS);

				// Some Cleaning
				cc.Dispose();

				return resultRate;
			}
		}

		public string Location
		{
			get
			{

				GeoIPService.GeoIPService geoIPSerive = new GeoIPService.GeoIPService();

				// Getting context geograpic info using an external WebService
				GeoIPService.GeoIP resultGeo = geoIPSerive.GetGeoIPContext();

				// Some Cleaning
				geoIPSerive.Dispose();

				return resultGeo.CountryName;
			}
		}

		public string NextRandomTip
		{
			get
			{
				TipService.Tips tipService = new TipService.Tips();

				// Getting the next random tip
				string randomTip = tipService.GetNextRandomTip();

				// Some Cleaning
				tipService.Dispose();

				return randomTip;
			}
		}

		
	}
}